#include <stdio.h>
#include <stdlib.h>

char* createStr(char* buff, int i);

int main(int argc, char* argv[])
{
	int i, n;
	char * buffer;
	
	printf("How long do you want the string? ");
	scanf("%d", &i);
	
	printf ("Random string: %s\n", createStr(buffer, i));

	free (buffer);
}

char* createStr(char* buffer, int i)
{
	int n = 0;
	buffer = (char*) malloc (i+1);

        if (buffer == NULL)
        {   
                exit (1);
        }   
        for (n=0; n<i; n++) 
        {   
                buffer[n] = rand() % 26 +'a';
        }   
        buffer[i]='\0';
	return buffer;
}
